package expandingproject;

import static expandingproject.ExpandingProject.heads;
import static expandingproject.ExpandingProject.tails;
import java.util.Random;
import java.util.Scanner;

/**
 *
 * @author Inderpreet
 */
public class CoinFlipper {

    public void flipACoin(int flips) {
        Random rand = new Random();
        for (int i = 0; i < flips; i++) {
            int randNum = rand.nextInt(2);
            if (randNum == 0) {
                heads++;
            } else {
                tails++;
            }
        }
    }

    public int getUserInput() {
        Scanner keyb = new Scanner(System.in);
        System.out.println("How many times would you like to flip the coin?");
        return Integer.parseInt(keyb.nextLine());
    }

    public void printResults(String winner) {
        System.out.println("Heads: " + heads);
        System.out.println("Tails: " + tails);
        if (winner.equalsIgnoreCase("Tie")) {
            System.out.println("It's a tie!");
        } else {
            System.out.println(winner + " wins");
        }
    }

    public String checkWinner() {
        if (heads > tails) {
            return "Heads";
        } else if (heads < tails) {
            return "Tails";
        } else {
            return "Tie";
        }
    }
}
